package com.library.mapper;

import com.library.entity.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {
    @Insert("INSERT INTO admin(username, password, role) VALUES(#{username}, #{password}, #{role})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Admin admin);
    
    @Select("SELECT * FROM admin WHERE username = #{username} AND password = #{password}")
    Admin findByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
    
    @Select("SELECT * FROM admin")
    List<Admin> findAll();
    
    @Update("UPDATE admin SET username=#{username}, password=#{password}, role=#{role} WHERE id=#{id}")
    int update(Admin admin);
    
    @Delete("DELETE FROM admin WHERE id=#{id}")
    int delete(Integer id);
} 